# Importing Data
JAPAN <- read_excel("C:/Users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "S1:S239")

# Checking the Imported Data
View(JAPAN)
# Creating Time Series Data
JAPAN_ts <- ts(JAPAN, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
JAPAN_ts
sum(is.na(JAPAN_ts))
library(forecast)
JAPAN_ts <- tsclean(JAPAN_ts)
JAPAN_ts

# Identification: Plotting the Time Series Data
plot(JAPAN_ts)

# Estimating the appropriate model
JAPAN_ts_model <- auto.arima(JAPAN_ts)
JAPAN_ts_model

# Forecasting
options(max.print=1000000)
JAPAN_ts_forecast <- forecast (JAPAN_ts_model, level=c(95), h=255)
plot(JAPAN_ts_forecast)
JAPAN_ts_forecast             

# Exporting
write.table(JAPAN_ts_forecast, file="/Users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/Japan_TSA.csv", sep=",")
